package com.friend.ui.util;

import android.os.Environment;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.h.cheng.pselector.base.load.IMediaLoader;

import java.io.File;

/**
 * 作者： ch
 * 时间： 2018/4/3 0003-下午 1:35
 * 描述：
 * 来源：
 */


public class BoxingGlideLoader implements IMediaLoader {
    @Override
    public void displayThumbnail(@NonNull ImageView img, @NonNull String absPath, int width, int height) {
        Glide.with(img.getContext()).load(absPath).apply(new RequestOptions().centerCrop().override(width, height)).into(img);
    }

    @Override
    public void displayIMG(@NonNull ImageView img, @NonNull String absPath, int width, int height) {
        Glide.with(img.getContext()).load(absPath).apply(new RequestOptions().centerCrop().override(width, height)).into(img);
    }

    @Override
    public void displayIMGNocrop(final ImageView img, @NonNull String absPath) {
        Glide.with(img.getContext()).load(absPath).apply(new RequestOptions().fitCenter()).into(img);
    }

    @Override
    public void downImg(String url, IMediaLoader.FileCallBack callBack) {
        String dirName = Environment.getExternalStorageDirectory() + "/chuangfen/";
        File f = new File(dirName);
        //不存在创建
        if (!f.exists()) {
            f.mkdirs();
        }
        File file = new File(dirName + System.currentTimeMillis() + ".jpg");
        //下载


    }

}
